package com.ruoyi.common.log.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.log.domain.*;
import com.ruoyi.common.log.domain.Process;
import com.ruoyi.common.log.service.CargoService;
import com.ruoyi.common.log.service.CropService;
import com.ruoyi.common.log.service.LogisticsService;
import com.ruoyi.common.log.service.ProcessService;
import com.ruoyi.common.log.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("logistics")
public class LogisticsController {

    @Autowired
    LogisticsService logisticsService;

    @Autowired
    CropService cropService;

    @Autowired
    ProcessService processService;

    @Autowired
    CargoService cargoService;

    @RequestMapping("logisticsList")
    public Result logisticsList(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "3") Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Logistics> list = logisticsService.logisticsList();
        PageInfo<Logistics> pageInfo = new PageInfo<>(list);
        return Result.success(pageInfo);
    }

    @RequestMapping("getCrop")
    public Result getCrop(){
        List<Crop> list = cropService.list();
        return Result.success(list);
    }

    @RequestMapping("getProcess")
    public Result getProcess(){
        List<Process> list = processService.list();
        return Result.success(list);
    }

    @RequestMapping("getCargo")
    public Result getCargo(){
        List<Cargo> list = cargoService.list();
        return Result.success(list);
    }
}
